<!DOCTYPE html>
<html>
<head>
    <!-- 页面meta -->
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <title>小力权限</title>
    <meta name="description" content="小力权限">
    <meta name="keywords" content="小力权限">
    <meta content="width=device-width,initial-scale=1,maximum-scale=1,user-scalable=no" name="viewport">
    <link rel="shortcut icon" href="../img/wangge.png">
    <!-- 引入样式 -->
    <link rel="stylesheet" href="../plugins/element-ui/lib/theme-chalk/index.css">
    <link rel="stylesheet" href="../plugins/font-awesome/css/font-awesome.min.css">
    <link rel="stylesheet" href="../css/style.css">
    <!-- 引入组件库 -->
    <script type="text/javascript" src="../js/vue.js"></script>
    <script type="text/javascript" src="../plugins/element-ui/lib/index.js"></script>
    <script type="text/javascript" src="../js/jquery.min.js"></script>
    <script type="text/javascript" src="../js/axios-0.18.0.js"></script>
    <style type="text/css">
        .el-main {
            position: absolute;
            top: 70px;
            bottom: 0px;
            left: 200px;
            right: 10px;
            padding: 0;
        }
    </style>
</head>
<body class="hold-transition skin-purple sidebar-mini">
<div id="app">
    <el-container>
        <el-header class="main-header" style="height:70px;">
            <nav class="navbar navbar-static-top" :class=''>
                <!-- Logo -->
                <a href="#" class="logo" style="text-align:center">
                    <span class="logo-lg"><img src="../img/wangge.png" width="171" height="30"></span>
                </a>
                <div class="right-menu">
                    <span class="help">
                        <!--<i class="fa fa-exclamation-circle" aria-hidden="true"></i>-->
                        <el-button type="text"
                                   icon="el-icon-chat-line-round"
                                   style="color: #f0f0f0"
                                   @click="openTheNotification">
                            <font color="#f0f8ff">帮助</font>
                        </el-button>
                    </span>
                    <el-dropdown class="avatar-container right-menu-item" trigger="click">
                        <div class="avatar-wrapper">
                            <img src="../img/user2-160x160.jpg" class="user-avatar">
                            {{username}}
                        </div>
                        <el-dropdown-menu slot="dropdown">
                            <div @click="handlePassword">
                                <el-dropdown-item divided>
                                    <span style="display:block;">修改密码</span>
                                </el-dropdown-item>
                            </div>
                            <a href="/logout.do">
                                <el-dropdown-item divided>
                                    <span style="display:block;">退出</span>
                                </el-dropdown-item>
                            </a>
                        </el-dropdown-menu>
                    </el-dropdown>
                </div>
            </nav>
        </el-header>
        <el-container>
            <el-aside width="200px">
                <el-menu>
                    <el-submenu v-for="(menu,index) in menuList" :index="menu.path" :key="index">
                        <template slot="title">
                            <i class="fa" :class="menu.icon"></i>
                            {{menu.name}}
                        </template>
                        <template v-for="child in menu.children">
                            <el-menu-item :index="child.path">
                                <a :href="child.linkUrl" target="right">{{child.name}}</a>
                            </el-menu-item>
                        </template>
                    </el-submenu>
                </el-menu>
            </el-aside>
            <el-container>
                <iframe name="right" class="el-main" src="work.html" width="100%" height="91%"
                        frameborder="0"></iframe>
            </el-container>
        </el-container>
    </el-container>

</div>
</body>
<script type="text/javascript">
    const vue = new Vue({
        el: '#app',
        data: {
            username: '',//当前登录用户的用户名
            menuList: [],
            popChange: false,
            user: {},
            conPassword: null,
            rules: {//校验规则 饿了么ui规定的
                password: [{required: true, message: '新密码为必填项', trigger: 'blur'}],
                oldPassword: [{required: true, message: '原密码为必填项', trigger: 'blur'}]
            }
        },
        created() {
            //发送ajax请求，请求Controller获取当前登录用户的用户名，展示到页面中
            axios.get("/user/getUsername.do").then((res) => {
                if (res.data.flag) {
                    this.username = res.data.data;
                    this.user.username = res.data.data;//回显到修改密码的用户名编辑框
                    axios.get("/menu/findMenuByUsername.do", {params: {"username": this.username}}).then((res) => {
                        if (res.data.flag) {
                            this.menuList = res.data.data;
                        } else {
                            this.$message(res.data.message);
                        }
                    })
                }
            });
        },
        methods: {

            handlePassword() {
                this.popChange = true;
                if (this.$refs["dataChangeForm"] !== undefined) {
                    this.$refs["dataChangeForm"].resetFields();
                    this.conPassword = null;
                }
            },
            openTheNotification() {
                const h = this.$createElement;
                this.$notify({
                    title: '关于本项目',
                    message: h('i', {style: 'color: teal'}, ''),
                    duration: 200,
                });
            },
        }
    });
    $(function () {
        var wd = 200;
        $(".el-main").css('width', $('body').width() - wd + 'px');
    });

    $(window).on('resize', function () {
        //屏幕大小自适应，重置容器高宽
        var wd = 200;
        $(".el-main").css('width', $('body').width() - wd + 'px');
    });
</script>
</html>
